Conversation
doesn't seem to be a reason for them to be in FlxCameraView? if I've overlooked something then we can easily move them back at some later point in time
|
I decided to deprecate all the internals and make them point to where they were moved, to avoid breaking anything. Addons and UI will need to be updated to avoid warnings, I'll get to that in a bit. Addons specifically seems to have an issue because I think this is in a good enough of a state now for a review, so I'll undraft |
|
Some more notes and thoughts. I'm currently playing around trying to implement an OpenGL renderer to really test the flexibility of this system. Overloading methods in FlxCameraView won't work:For stuff like FlxMaterial and FlxTrianglesData, the function signatures of the core rendering functions need to be changed. To avoid breaking changes, I was just going to do this with overloads, but that didn't work out because overloads need to be inlined and you can't override inline functions. I got around this by deprecating drawPixels() and copyPixels() for draw() and copy() in FlxCameraView, but I couldn't do the same in FlxCamera because it inherits FlxBasic.draw(). I ended up overloading the camera's drawPixels() and copyPixels() to call the new methods in camera view. Pretty gross solution IMO but I can't think of a better way without a breaking change. Unifying renderBlit with other renderersI did some work related to this in 3cd97d9, but there's still a couple places where we have to do things differently depending on the renderer, notably Lines 743 to 744 in c32ab91 When the blitting renderer is used, Isolating direct access to renderer
EDIT 2: This is no longer an issue with recent changes, see next comment |
WIP; debug drawing is not functional yet and there's a bunch of temporary code that needs to be cleaned up
|
Originally this was just a port of the renderer abstraction by Beeblerox that I ported over to modern Flixel. As I was playing around with it, I found that there were certain things I wasn't too fond of, specifically the fact that access to the renderer was only possible through cameras, so here goes an attempt at a V2.
Considering that the renderer is now global, I've also integrated some of the helpers mentioned in #3527 directly into I also wonder if it'd be worth deprecating the drawing methods in |
|
I think this is now in a reviewable state. No clue why CI is failing tho |
|
Gonna try a couple things, I'll let you know when I'm done, hopefully by sometime tomorrow |
Co-authored-by: ACrazyTown <47027981+ACrazyTown@users.noreply.github.com>
|
quoted from #3567
The important distinction I wanna make is that, while we may move the rendering somewhere else, I do think it's important that to draw a sprite to a camera's view, you should call something akin to
The reason I make FlxVertexBuffer an abstract, is so that method args could be changed to take that type without breaking existing calls to it (as Graphics and FlxVertexBuffer can be implicitly casted to one another). Once devs migrate, FlxVertexBuffer will be a different type that will allow (or wrap) various underlying types. 1 option is to make it a class wrapper with derived types that use each specific underlying type. Another option is an abstract OneOfMany<T...> that calls the appropriate renderer |
Might rename again in the future to something more debug oriented...?
Yeah this makes sense. To be clear, I'm not against putting the render methods in camera view, I'm moreso against tying them to cameras specifically, as this would lead us further away from separating cameras and rendering (#1073). It'll be easier to reason with this once we have all the missing pieces, so my focus now is to implement In the meantime, I'd appreciate any help on #3566, as I think that's going to be one of the toughest parts to figure out.
I don't think I can make
Hooking it up is doable, it's just an extreme hassle because everything expects a |
Was causing crashes with the GL renderer as it doesn't use the FlxDrawItems at all. Seems like there's no functional difference between manually adding quads to a batch and just calling drawFrame() and having it done automatically.
|
@Geokureli I've opened up a PR for FlxTexture: ACrazyTown#2 |
| public function drawTriangles(graphic:FlxGraphic, vertices:FlxVector2d<Float>, indices:FlxVector2d<Int>, uvtData:FlxVector2d<Float>, ?colors:FlxVector2d<Int>, | ||
| ?position:FlxPoint, ?blend:BlendMode, repeat:Bool = false, smoothing:Bool = false, ?transform:ColorTransform, ?shader:FlxShader) |
There was a problem hiding this comment.
@Geokureli Is FlxVector2d meant to act as an abstraction over openfl's Vector, that would eventually become a new class, or is it just a helper? It makes sense for positions and uvs, which are treated as (x, y) pairs, but it doesn't make sense to use it for indices and colors which have a value per coordinate pair. (They're half the length of vertices)
addition takes precedence over bitwise ops and was causing invalid/inaccurate values https://haxe.org/manual/expression-operators-precedence.html
Here we go, first step towards a renderer overhaul. Looks like a pretty big and scary change but 99% of this is just moving stuff around.
Shout out goes to Beeblerox & Austin East, a lot of this is based on the original renderer overhaul branch, I'm just porting bits and pieces to modern Flixel.
Changes
FlxRenderer
Adds a base
FlxRendererclass, accessible via the globalFlxG.renderer, which serves as the base for all rendering functionality. Renderer implementations extend it and implement the required methods.The blitting and draw quads renderers have been ported to
FlxBlitRendererandFlxQuadRenderer, respectively.Since the renderer is a global thing, and not per-camera anymore, it works slightly differently. Before any calls to drawing commands you need to call
FlxG.renderer.begin(camera);. This will be done internally by Flixel during a sprite's draw phase, but it's something to keep in mind if you're doing something out of the ordinary!FlxCameraView
Adds a base
FlxCameraViewclass. Like with renderers, different implementations extend the base class and add onto it. Camera views mainly just hold per-camera rendering related objects, stuff like OpenFL sprites and whatnot.To avoid breaking changes, you can get a typed reference to the camera view using the
camera.viewBlitandcamera.viewQuadshortcuts. Use this to reference stuff likecamera.flashSpriteorcamera.canvas.Other previously established stuff
Most rendering methods from
FlxCamerahave been deprecated. If you need to issue drawing commands manually, use theFlxG.rendererAPI instead.I say most because some batch related methods (e.g.
startQuadBatch()) have been left as-is. I plan to tackle these at a later point and in a different PR.I'm opening this as a DRAFT, because:
Would be nice to add docs to a bunch of stuffI don't know what to do with a bunch of private internal variables in FlxCamera and alike. What's Flixel's way of handling this? Should I simply get rid of them, or deprecate them and make them point to where they were moved?TODO: